package org.zjt.book

import scala.collection.mutable

/**
  * Created by Administrator on 2017/5/2.
  */
object TestMap2 extends App{

  // TODO:  immutable包 不能更新元素
  var var1 = Map(1->"zhangsan",2->"lisi",3->"wangwu")
  var1 += 4->"hskjd"
  println(var1.mkString(","))




  // TODO:  mutable下面的方法都可以更新元素
  var var2 = new mutable.HashMap[String,Int]()

  // += 追加一个或者多个元素
  var2 += ("sss"->2)
  println(var2.mkString(","))
  var2 += ("sda"->2,"dsds"->2)
  println( var2.mkString(","))

  //更新/添加映射
  var2("zhang") = 222
  println(var2.mkString(","))


  //++:
  var2 ++: var1
  println(var2.mkString(","))





















}
